unit Ensemble1;

interface
uses
  Classes;

type
  TEnsemble1 = class
  private
    FValuesList : TStringList;
  public
    constructor Create;

    function BestByRank     : Integer;

    property ValuesList : TStringList read FValuesList write FValuesList;

  end;

implementation

uses SysUtils;

{ TEnsemble1 }

function TEnsemble1.BestByRank: Integer;
var
  i : Integer;
  a : array[0..9] of Integer;

  maior : Integer;
begin
  for i := 0 to 9 do
    a[i] := 0;

  Result := 0;
  for i := 0 to FValuesList.Count-1 do
    begin
      Inc(a[StrToInt(FValuesList[i])]);

    end;

  maior := 0;

  for i := 0 to 9 do
    begin
      if a[i] > maior then
        begin
          maior := a[i];
          Result := i;
        end;

    end;

end;

constructor TEnsemble1.Create;
begin
  FValuesList := TStringList.Create;
end;

end.
